/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* removeNthFromEnd(struct ListNode* head, int n) {
    struct ListNode dummy = {0, head};//可能会删除头节点，因此要借助哨兵位
    struct ListNode *left = &dummy, *right = &dummy;
    while(n--){
        right = right->next;
    }
    while(right->next){
        left = left->next;
        right = right->next;
    }
    struct LaistNode *cur = left->next;
    left->next = left->next->next;
    free(cur);
    return dummy.next;
}

/*给你一个链表，删除链表的倒数第 n 个结点，并且返回链表的头结点。*/